﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using LibNiconico.NiconicoApi.Internal;
using LibNiconico.NiconicoApi.Extentions;

namespace LibNiconico.NiconicoApi.PlayerStatus
{
    public sealed partial class NicoPlayerStatus
    {
        public sealed partial class InternalClasses
        {
            /// <summary>
            /// RTMP情報
            /// </summary>
            public sealed class Rtmp
            {
                /// <summary>
                /// ストリーミングURL
                /// </summary>
                public Uri Url { get; private set; }

                /// <summary>
                /// チケット
                /// </summary>
                public string Ticket { get; private set; }

                internal static Rtmp Parse(XElement element)
                {
                    Rtmp rtmp = XElementExtention.Parse(element, "rtmp", item =>
                    {
                        return new Rtmp
                        {
                            Url = XElementExtention.GetElementAsUri(item, "url"),
                            Ticket = XElementExtention.GetElementAsString(item, "ticket")
                        };

                        
                    });

                    return rtmp == null ? new Rtmp() : rtmp;
                }

                internal Rtmp() 
                {
                    this.Url = default(Uri);
                    this.Ticket = "";
                }
            }
        }
    }
}
